import { COLUMN_WIDTH } from '@/utils/service.js'

/* 稿件转发指令模板 */
export const createColumns_manu = (vm) => [
  /* {
    title: '',
    width: 34,
    align: 'center',
    type: 'selection',
  }, */
  {
    title: '序号',
    key: 'id',
    align: 'center',
    width: 80,
    render(h, params) {
      return <div>{(vm.formData.pageNo - 1) * vm.formData.pageSize + params.index + 1}</div>
    },
  },
  {
    title: '稿件标题',
    align: 'center',
    // width: COLUMN_WIDTH + 340,
    render(h, params) {
      return <article-title info={params.row}></article-title>
    },
  },
  { title: '稿件链接', key: '', align: 'center' },
  { title: '执行网站', key: '', align: 'center' },
  { title: '发稿时间', key: '', align: 'center' },
  { title: '发布位置', key: '', align: 'center' },
  { title: '上稿时长(分钟)', width: COLUMN_WIDTH - 20, key: '', align: 'center' },
  { title: '点击量(万次)', width: COLUMN_WIDTH - 30, key: '', align: 'center' },
  { title: '点赞量(万次)', width: COLUMN_WIDTH - 30, key: '', align: 'center' },
  { title: '转发量(万次)', width: COLUMN_WIDTH - 30, key: '', align: 'center' },
  { title: '评论量(万次)', width: COLUMN_WIDTH - 30, key: '', align: 'center' },
  { title: '收藏量(万次)', width: COLUMN_WIDTH - 30, key: '', align: 'center' },
]

/* 专题专栏指令模板 */
export const createColumns_subject = (vm) => [
  {
    title: '序号',
    key: 'id',
    align: 'center',
    width: 80,
    render(h, params) {
      return <div>{(vm.formData.pageNo - 1) * vm.formData.pageSize + params.index + 1}</div>
    },
  },
  { title: '专题名称', key: '', align: 'center' },
  { title: '专题链接', key: '', align: 'center' },
  { title: '执行网站', key: '', align: 'center' },
  { title: '上线时间', key: '', align: 'center' },
  { title: '位置', key: '', align: 'center' },
  { title: '开设时长(分钟)', key: '', align: 'center' },
  { title: '稿件总量(篇)', key: '', align: 'center' },
  { title: '附件链接', key: '', align: 'center' },
]

/* 话题上榜指令模板 */
export const createColumns_topic = (vm) => [
  {
    title: '序号',
    key: 'id',
    align: 'center',
    width: 80,
    render(h, params) {
      return <div>{(vm.formData.pageNo - 1) * vm.formData.pageSize + params.index + 1}</div>
    },
  },
  { title: '话题名称', key: '', align: 'center' },
  { title: '话题链接', key: '', align: 'center' },
  { title: '上榜网站', key: '', align: 'center' },
  { title: '阅读量(万次)', width: COLUMN_WIDTH - 30, key: '', align: 'center' },
  { title: '评论量(万次)', width: COLUMN_WIDTH - 30, key: '', align: 'center' },
  { title: '相关话题量(个)', key: '', align: 'center' },
  { title: '上榜时间', key: '', align: 'center' },
  { title: '上榜位置', key: '', align: 'center' },
  { title: '最高排名', key: '', align: 'center' },
  { title: '上榜时长(分钟)', width: COLUMN_WIDTH - 20, key: '', align: 'center' },
  { title: '附件链接', key: '', align: 'center' },
]

/* 开机屏 指令模板 */
export const createColumns_startUp = (vm) => [
  {
    title: '序号',
    key: 'id',
    align: 'center',
    width: 80,
    render(h, params) {
      return <div>{(vm.formData.pageNo - 1) * vm.formData.pageSize + params.index + 1}</div>
    },
  },
  { title: '开机屏标题', key: '', align: 'center' },
  { title: '转发网站', key: '', align: 'center' },
  { title: '执行时间', key: '', align: 'center' },
  { title: '刷出次数(次)', key: '', align: 'center' },
  { title: '上线时长(分钟)', key: '', align: 'center' },
]

/* 其他指令报送数据模板（主题） */
export const createColumns_otherTheme = (vm) => [
  {
    title: '序号',
    key: 'id',
    align: 'center',
    width: 80,
    render(h, params) {
      return <div>{(vm.formData.pageNo - 1) * vm.formData.pageSize + params.index + 1}</div>
    },
  },
  { title: '主题标题', key: '', align: 'center' },
  { title: '作品数量(个)', key: '', align: 'center' },
  { title: '阅读量(万次)', key: '', align: 'center' },
  { title: '播放量(万次)', key: '', align: 'center' },
  { title: '点赞量(万次)', key: '', align: 'center' },
  { title: '评论量(万次)', key: '', align: 'center' },
  { title: '转发量(万次)', key: '', align: 'center' },
]

/* 其他指令报送数据模板（话题组） */
export const createColumns_otherTopic = (vm) => [
  {
    title: '序号',
    key: 'id',
    align: 'center',
    width: 80,
    render(h, params) {
      return <div>{(vm.formData.pageNo - 1) * vm.formData.pageSize + params.index + 1}</div>
    },
  },
  { title: '话题标题', key: '', align: 'center' },
  { title: '话题链接', key: '', align: 'center' },
  { title: '话题数(条)', key: '', align: 'center' },
  { title: '阅读量(万次)', key: '', align: 'center' },
  { title: '讨论量(万次)', key: '', align: 'center' },
  { title: '上榜情况', key: '', align: 'center' },
]

export const feedbackTemplateMap = new Map([
  ['manu', createColumns_manu],
  ['subject', createColumns_subject],
  ['topic', createColumns_topic],
  ['startUp', createColumns_startUp],
  ['otherTheme', createColumns_otherTheme],
  ['otherTopic', createColumns_otherTopic],
])

/* 指令详细信息 */
export const createColumns_directiveInfo = (vm) => {
  const { columns = [] } = vm.currentFbTem
  const resColumns = [
    {
      title: '序号',
      key: 'id',
      align: 'center',
      width: 80,
      render(h, params) {
        return <div>{(vm.formData.pageNo - 1) * vm.formData.pageSize + params.index + 1}</div>
      },
    },
    {
      title: columns[1] && columns[1].title,
      align: 'center',
      render(h, params) {
        if (params.row.editable) {
          // 要注意分页时
          const i = (vm.formData.pageNo - 1) * vm.formData.pageSize + params.index
          return <i-input value={vm.tableData[i].title} on-input={(val) => (vm.tableData[i].title = val)}></i-input>
        } else {
          return (
            <div class="ellipsis" title={params.row.title}>
              {' '}
              {params.row.title}
            </div>
          )
        }
      },
    },
    {
      title: columns[2] && columns[2].title,
      align: 'center',
      render(h, params) {
        if (params.row.editable) {
          // 要注意分页时
          const i = (vm.formData.pageNo - 1) * vm.formData.pageSize + params.index
          return <i-input value={vm.tableData[i].url} on-input={(val) => (vm.tableData[i].url = val)}></i-input>
        } else {
          return (
            <div class="ellipsis" title={params.row.url}>
              {' '}
              {params.row.url}
            </div>
          )
        }
      },
    },
  ]

  const column_operation = {
    title: '操作',
    align: 'center',
    width: 200,
    render(h, params) {
      return (
        <div>
          <icon-button
            icon="remove"
            title="删除"
            width="15"
            height="17"
            style="vertical-align: -5px;"
            activated={false}
            nativeOnClick={() => {
              vm.handleTableDataDetele(params)
            }}
          ></icon-button>
          {/* <tag color="error" class="f12 cursor-default ml14">重复</tag> */}
        </div>
      )
    },
  }

  const op = vm.from === 'create' || vm.from === 'issue'
  return op ? resColumns.concat(column_operation) : resColumns
}
